export const checkEnv = () => {
	const href = window.location.href

	if (process.env.NODE_ENV === 'development') return 'isLocal'

	if (/(www.mvpzm.com)/.test(href))
		return 'isPrd'

	if (/(120.76.200.86)/.test(href)) {
		return 'stg1'
	}
	if (/(lcdp-bld-stg3.paic.com.cn)/.test(href)) {
		return 'stg3'
	}

	return ''
}

export const getCommonApi = () => {
	let VITE_PUBLIC_KEY, VITE_HOST
	switch (checkEnv()) {
		case 'isLocal':
			VITE_HOST = '/api'
			VITE_PUBLIC_KEY = 'Y2rn4ePkix7aQqe$'
			break
		case 'stg1':
			VITE_HOST = 'http://119.23.255.123:9010'
			VITE_PUBLIC_KEY = 'Y2rn4ePkix7aQqe$'
			break
		case 'isPrd':
			VITE_HOST = 'http://120.76.249.124:9010'
			VITE_PUBLIC_KEY = 'Y2rn4ePkix7aQqe$'
			break
		default:
			VITE_HOST = '/api'
			VITE_PUBLIC_KEY = 'Y2rn4ePkix7aQqe$'
		// throw new Error('未兼容的场景❗️')
	}
	return { VITE_PUBLIC_KEY, VITE_HOST }
}